package com.example.day12;

/**
 * @author Lenovo
 */
public class ArrayDemo {
    public static void main(String[] args) {
        int[] arr = {24,69,80,57,13};
        System.out.println("排序前："+arrayToString(arr));
        for (int i = 0; i < arr.length - 1; i++){
            for (int j = 0; j < arr.length - 1 - i; j++){
                if (arr[j] > arr[j + 1]){
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        System.out.println("排序后："+arrayToString(arr));
    }
    public static String arrayToString(int[] arr){
        String str = "[";
        for (int i = 0; i < arr.length; i++){
            if (i == arr.length - 1){
                str += arr[i];
            }else {
                str += arr[i] + ",";
            }
        }
        str += "]";
        return str;
    }


}
